package 领扣算法.力扣计划.算法基础.子集;

import java.util.LinkedList;
import java.util.List;

public class Main {
    LinkedList<List<Integer>> res=new LinkedList<>();
    public List<List<Integer>> subsets(int[] nums) {
        LinkedList<Integer> middle=new LinkedList<>();
        for (int num : nums) {
            middle.add(num);
        }
        plus(new LinkedList<Integer>(middle),new LinkedList<Integer>());
        return res;
    }

    private void plus(LinkedList<Integer> integers, LinkedList<Integer> middle) {
        res.add(new LinkedList<>(middle));
        if (integers.isEmpty())
            return;
        while (!integers.isEmpty()){
            LinkedList<Integer> middle1 = new LinkedList<>(middle);
            middle1.add(integers.poll());
            plus(new LinkedList<>(integers),middle1);
        }
    }

}
